#include "GameCC.h"

char szAppPath[_MAX_PATH];

void ClearScreen(void)
{
   system("cls");
}

char* GetIniFileName(void)
{
   GetModuleFileName(0, szAppPath, MAX_PATH);
   int len = strlen(szAppPath);
   if (len > 5)
   {
      szAppPath[len-3] = 'i';
      szAppPath[len-2] = 'n';
      szAppPath[len-1] = 'i';
   }
   return szAppPath;
}

int GetRandomNumber(int Limit)
{
	if (Limit <= 0)
		return 0;
	else
		return rand() % Limit;
}

char szBuffer[MAX_ENTRY];
char* GetString(char* Message)
{
	puts(Message);
	return gets(szBuffer);
}

char* NextToken(char* pArg, char cDelimiter)
{
   return strchr(pArg, cDelimiter) + 1;
}

bool PrintFile(char* FileName)
{
   FILE *stream;
   char line[MAX_ENTRY];

   ClearScreen();

   if( (stream = fopen(FileName, "r" )) != NULL )
   {
      while(fgets(line, MAX_ENTRY, stream))
         printf("%s", line);
      fclose(stream);
      WaitForKey(PRESS_ANY_KEY);
      return true;
   }
   else
      return false;

}

char WaitForKey(char* Message)
{
   if (strlen(Message) > 0)
      puts(Message);
   return _getch();
}
